package com.chenfwind.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chenfwind.IDao.FriendMapper;
import com.chenfwind.common.StringUtils;
import com.chenfwind.domain.Friend;
import com.chenfwind.service.FriendService;

@Service("friendService")
public class FriendServiceImpl implements FriendService {

	@Autowired
	private FriendMapper friendDao;
	
	public int save(Friend friend) {
		Friend friend2 = new Friend();
		friend2.setId(StringUtils.genUUID());
		friend2.setUser1Id(friend.getUser2Id());
		friend2.setUser2Id(friend.getUser1Id());
		friend2.setCreateTime(friend.getCreateTime());
		friendDao.insertSelective(friend2);
		return friendDao.insertSelective(friend);
	}

	public List<Friend> getAllFriend(String userId) {
		return friendDao.selectFriendByUserId(userId);
	}

	public Friend findFriendByUid1AndUid2(String uid1 , String uid2){
		return friendDao.selectByUid1AndUid2(uid1, uid2);
	}
	
}
